package com.lock.lockblog.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class AppEnum {
	
/*	public enum AuthorityType{
		member,
		shop,
		admin
	}*/
	
	/**
	 * 水印位置
	 */
	public enum WatermarkPosition {

		/** 无 */
		no,

		/** 左上 */
		topLeft,

		/** 右上 */
		topRight,

		/** 居中 */
		center,

		/** 左下 */
		bottomLeft,

		/** 右下 */
		bottomRight
	}
	
	/**
	 * 类型
	 */
	public enum TagType {

		/** 文章标签 */
		article,

		/** 商品标签 */
		product
	};
	
	/**
	 * 返回类型的枚举值
	 * @author Administrator
	 *
	 */
	public enum ResultTypeEnum{
		page,json;
	}
	
	/**
	 * 权限枚举声明
	 * @author Administrator
	 *
	 */
 	public enum Authority{
		product_product(0,"商品管理",100),
		product_productCategory(0,"商品分类管理",102), 
		product_parameterGroup(0,"商品参数管理",103), 
		product_attribute(0,"商品属性管理 ",104),
		product_specification(0,"规格管理",105), 
		product_brand(0,"品牌管理",106),
		product_productNotify(0,"到货通知管理",107),
		product_mingzhuang(0,"明庄管理",108),
		product_origin(0,"产地管理",109),

		order_order(1,"订单管理",200),
		order_print(1,"打印管理",201), 
		order_payment(1,"收款管理",202), 
		order_refunds(1,"退款管理",203), 
		order_shipping(1,"发货管理",204), 
		order_returns(1,"退货管理",205), 
		order_deliveryCenter(1,"发货点管理",206), 
		order_deliveryTemplate(1,"快递单模板管理",207),
		
		member_member(2,"会员管理",300),
		member_memberRank(2,"会员等级管理",301),
		member_memberAttribute(2,"会员注册项管理",302),
		member_review(2,"评论管理",303),
		member_consultation(2,"咨询管理",304),
		member_card_leve(2,"会员卡等级管理",305),
		member_open_card(2,"开卡管理",306),
		member_card_exception_handling (2,"会员卡异常管理",307),

		content_navigation(3,"导航管理",401),
		content_article(3,"文章管理",402),
		content_articleCategory(3,"文章分类管理",403),
		content_tag(3,"标签管理",404),
		content_friendLink(3,"友情链接管理",405),
		content_adPosition(3,"广告位管理",406),
		content_ad(3,"广告管理",407),
		content_template(3,"模板管理",408),
		content_cache(3,"缓存管理",409),
		content_index(3,"索引管理",410),
				
		marketing_promotion(4,"促销管理",501),
		marketing_coupon(4,"优惠券管理",502),
		marketing_seo(4,"SEO",503),

		statistics_statistics(5,"访问统计管理",601),
		statistics_sales(5,"销售统计",602),
		statistics_salesRanking(5,"销售排行",603),
		statistics_purchaseRanking(5,"消费排行",604),
		statistics_deposit(5,"预存款",605),
		
		
		setting_setting(6,"系统设置",701),
		setting_area(6,"地区管理",702),
		setting_paymentMethod(6,"支付方式管理",703),
		setting_shippingMethod(6,"配送方式管理",704),
		setting_deliveryCorp(6,"物流公司管理",705),
		setting_paymentPlugin(6,"支付插件",706),
		setting_admin(6,"管理员管理",707),
		setting_role(6,"角色管理",708),
		setting_message(6,"消息管理",709),
		setting_log(6,"日志管理",710);
		
		
 		
		/**
		 * 权限数组
		 */
		private static final  String[] AuthorityGroupList = {"商品管理","订单管理","会员管理","内容管理","营销管理","统计管理","系统设置"};
		/**
		 * 枚举值缓存
		 */
		private static HashMap<Integer, Authority> AuthorityCache = new HashMap<>();
		
		static{
			Authority[] authArray = Authority.values();
			for (int i = 0; i < authArray.length; i++) {
				final Authority auth = authArray[i];
				AuthorityCache.put(auth.getValue(), auth);
			}
		}
		
		/**
		 * 返回一个group by的数组
		 * @return
		 */
		@SuppressWarnings("serial")
		public static HashMap<String, List<Authority>> getAuthorityMap() {
			HashMap<String, List<Authority>> authMap = new HashMap<>();
			
			Authority[] authArray = Authority.values();
			for (int i = 0; i < authArray.length; i++) {
				final Authority auth = authArray[i];
				if(authMap.containsKey(auth.getGroupName())){
					authMap.get(auth.getGroupName()).add(auth);
				}else{
					authMap.put(auth.getGroupName(),new ArrayList<Authority>(){{add(auth);}});
				}
			}
			
			return authMap;
		}
		
		/**
		 * 根据value,返回对应的枚举值
		 * @param value
		 * @return
		 */
		public static Authority valueOf(int value){
			return AuthorityCache.get(value);
		}
		
		int groupId;
		public int getGroup() {
			return groupId;
		}
		
		public String getGroupName() {
			return AuthorityGroupList[groupId];
		}
		
		public void setGroup(int groupId) {
			this.groupId = groupId;
		}
		public String getName() {
			return authName;
		}
		public void setName(String authName) {
			this.authName = authName;
		}
		public int getValue() {
			return value;
		}
		public void setValue(int value) {
			this.value = value;
		}
		String authName;
		int value;
		private Authority(int groupId,String authName,int value){
			
			this.groupId = groupId;
			this.authName = authName;
			this.value = value;
		}
	}
}
